﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

#nullable disable

namespace CzJ_VoteSys.Models.Database
{
    [Index(nameof(Email), Name = "UQ__Users__A9D1053413E12D1D", IsUnique = true)]
    [Index(nameof(Email), Name = "idx_Users_Email")]
    public partial class User
    {
        public User()
        {
            Participations = new HashSet<Participation>();
            VoteRecords = new HashSet<VoteRecord>();
        }

        [Key]
        [Column("UserID")]
        public int UserId { get; set; }
        [Required]
        [StringLength(255)]
        public string Email { get; set; }
        [Required]
        [StringLength(32)]
        public string UserPassword { get; set; }
        [Required]
        [StringLength(32)]
        public string Salt { get; set; }
        [Required]
        [StringLength(50)]
        public string RoleType { get; set; }
        [Column(TypeName = "datetime")]
        public DateTime LastVoteDate { get; set; }
        public int LastVoteCount { get; set; }

        [InverseProperty(nameof(Participation.User))]
        public virtual ICollection<Participation> Participations { get; set; }
        [InverseProperty(nameof(VoteRecord.User))]
        public virtual ICollection<VoteRecord> VoteRecords { get; set; }
    }
}
